package main

func main()  {

}

type minDeepTreeNode struct {
	val int
	left *minDeepTreeNode
	right *minDeepTreeNode
}
func minDeep(root *minDeepTreeNode) int {
	if root == nil {
		return 0
	}
	if root.left == nil {
		return minDeep(root.right) + 1
	}
	if root.right == nil {
		return minDeep(root.left) + 1
	}
	leftHigh := minDeep(root.left)+1
	rightHigh := minDeep(root.right)+1
	if leftHigh < rightHigh {
		return leftHigh
	}else {
		return rightHigh
	}
}